import QtQuick 2.15
import QtQuick.Controls 2.15

Page {
    property string pageTitle: ""
    property string pageIcon: ""

    Rectangle {
        anchors.fill: parent
        color: "#f5f5f5"

        Column {
            anchors.fill: parent

            // 通用标题栏
            Rectangle {
                width: parent.width
                height: 60
                color: "#ffffff"

                Row {
                    anchors.left: parent.left
                    anchors.leftMargin: 20
                    anchors.verticalCenter: parent.verticalCenter
                    spacing: 15

                    MouseArea {
                        width: 30
                        height: 30

                        Rectangle {
                            anchors.fill: parent
                            color: parent.pressed ? "#e0e0e0" : "transparent"
                            radius: 15

                            Text {
                                text: "←"
                                font.pixelSize: 18
                                anchors.centerIn: parent
                                color: "#007AFF"
                            }
                        }

                        onClicked: stackView.pop()
                    }

                    Text {
                        text: pageIcon
                        font.pixelSize: 18
                        anchors.verticalCenter: parent.verticalCenter
                    }

                    Text {
                        text: pageTitle
                        font.pixelSize: 18
                        font.bold: true
                        anchors.verticalCenter: parent.verticalCenter
                    }
                }
            }

            // 内容区域 - 子类可以重写
            Rectangle {
                width: parent.width
                height: parent.height - 60
                color: "#ffffff"

                default property alias content: contentArea.data

                Item {
                    id: contentArea
                    anchors.fill: parent
                }
            }
        }
    }
}
